package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 客户账单表
 */
@JsonApiResource(type = "customerbill")
@Table(name = "tnb_customer_bill")
@Entity
public class CustomerBill extends BaseEntity {
	private String remark;// 备注

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	// private TradeAccount account;// 账户

	private Customer customer;

	private Double total1;// 金额

	private Double total2;// 金额

	private Double total3;// 金额

	private Double total;// 账单总金额

	private User operateUser;// 审核人

	private Integer operateTime;// 审核时间

	private String operateRemark;// 审核备注

	private Dicttype billStatus;// 记录状态

	private Dicttype billType;// 账单类型

	private Integer billTime;// 账单日期

	private Integer billYear;// 账单年

	private Integer billQuarter;// 账单季度/ 日统计账单为最后一天账单时间

	private Integer billMonth;// 账单月份

	private Dicttype billCreateType;// 账单生成类型

	private CustomerBusinessFlow flow;// 业务表

	private Dicttype billStatType;// 账单统计类型

	private String operateFlag;// 1有服务变更 0无服务变更

	@Column(name = "operate_flag")
	public String getOperateFlag() {
		return operateFlag;
	}

	public void setOperateFlag(String operateFlag) {
		this.operateFlag = operateFlag;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "billstat_type", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getBillStatType() {
		return billStatType;
	}

	public void setBillStatType(Dicttype billStatType) {
		this.billStatType = billStatType;
	}

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "flow_id", foreignKey = @ForeignKey(name = "null"))
	public CustomerBusinessFlow getFlow() {
		return flow;
	}

	public void setFlow(CustomerBusinessFlow flow) {
		this.flow = flow;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "billcreate_type", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getBillCreateType() {
		return billCreateType;
	}

	public void setBillCreateType(Dicttype billCreateType) {
		this.billCreateType = billCreateType;
	}

	@Column(name = "bill_time")
	public Integer getBillTime() {
		return billTime;
	}

	public void setBillTime(Integer billTime) {
		this.billTime = billTime;
	}

	@Column(name = "bill_year")
	public Integer getBillYear() {
		return billYear;
	}

	public void setBillYear(Integer billYear) {
		this.billYear = billYear;
	}

	@Column(name = "bill_quarter")
	public Integer getBillQuarter() {
		return billQuarter;
	}

	public void setBillQuarter(Integer billQuarter) {
		this.billQuarter = billQuarter;
	}

	@Column(name = "bill_momth")
	public Integer getBillMonth() {
		return billMonth;
	}

	public void setBillMonth(Integer billMonth) {
		this.billMonth = billMonth;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "bill_type", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getBillType() {
		return billType;
	}

	public void setBillType(Dicttype billType) {
		this.billType = billType;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "operateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getOperateUser() {
		return operateUser;
	}

	public void setOperateUser(User operateUser) {
		this.operateUser = operateUser;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "status_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getBillStatus() {
		return billStatus;
	}

	public void setBillStatus(Dicttype billStatus) {
		this.billStatus = billStatus;
	}

	@Column(name = "operate_time")
	public Integer getOperateTime() {
		return operateTime;
	}

	public void setOperateTime(Integer operateTime) {
		this.operateTime = operateTime;
	}

	// @JsonApiToOne
	// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	// @JoinColumn(name = "account_id", foreignKey = @ForeignKey(name = "null"))
	// public TradeAccount getAccount() {
	// return account;
	// }
	//
	// public void setAccount(TradeAccount account) {
	// this.account = account;
	// }

	@Column(name = "total3")
	public Double getTotal3() {
		return total3;
	}

	public void setTotal3(Double total3) {
		if (total3 == null) {
			total3 = 0.0;
		}
		this.total3 = total3;
	}

	@Column(name = "total")
	public Double getTotal() {
		return total;
	}

	public void setTotal(Double total) {
		if (total == null) {
			total = 0.0;
		}
		this.total = total;
	}

	@Column(name = "total2")
	public Double getTotal2() {
		return total2;
	}

	public void setTotal2(Double total2) {
		if (total2 == null) {
			total2 = 0.0;
		}
		this.total2 = total2;
	}

	@Column(name = "total1")
	public Double getTotal1() {
		return total1;
	}

	public void setTotal1(Double total1) {
		if (total1 == null) {
			total1 = 0.0;
		}
		this.total1 = total1;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	public CustomerBill() {

	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "operate_remark")
	public String getOperateRemark() {
		return operateRemark;
	}

	public void setOperateRemark(String operateRemark) {
		this.operateRemark = operateRemark;
	}

}
